package com.kc.web.controller.business;

import com.kc.business.domain.BizCelebrityEnterForm;
import com.kc.business.service.IBizCelebrityEnterService;
import com.kc.common.annotation.Log;
import com.kc.common.annotation.RepeatSubmit;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO
 * 名家入驻
 *
 * @author zhangshuo
 * @version 1.0
 * @date 2020/9/11
 */
@RestController
@RequestMapping("/business/celebrityEnter")
public class BizCelebrityEnterController extends BaseController {
    @Autowired
    private IBizCelebrityEnterService bizCelebrityEnterService;

    /**
     * 入驻列表
     *
     * @param celebrityEnterForm
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:celebrityEnter:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizCelebrityEnterForm celebrityEnterForm) {
        startPage();
        List<BizCelebrityEnterForm> list = bizCelebrityEnterService.getList(celebrityEnterForm);
        return getDataTable(list);
    }

    /**
     * 新增入驻
     *
     * @param celebrityEnterForm
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:celebrityEnter:edit')")
    @Log(title = "名家入驻管理", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@Validated @RequestBody BizCelebrityEnterForm celebrityEnterForm) {
        return toAjax(bizCelebrityEnterService.add(celebrityEnterForm));
    }

    /**
     * 修改入驻
     *
     * @param celebrityEnterForm
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:celebrityEnter:edit')")
    @Log(title = "名家入驻管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @RepeatSubmit
    public AjaxResult edit(@Validated @RequestBody BizCelebrityEnterForm celebrityEnterForm) {
        return toAjax(bizCelebrityEnterService.edit(celebrityEnterForm));
    }
}
